package com.xiamaliu.dynamic;

import sun.misc.ProxyGenerator;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class JDKProxyTest {
    public static void main(String[] args) throws IOException {
        JdkMeipo iPerson = new JdkMeipo();
        IPerson zhaoliu = iPerson.getInstance(new ZhaoLiu());
        zhaoliu.findLove();

        byte[] bytes = ProxyGenerator.generateProxyClass("$Proxy0", new Class[]{IPerson.class});
        FileOutputStream os = new FileOutputStream("/Users/fengzhaowang/java/MyCode/gupaoedu/pattern-proxy/src/main/java/com/xiamaliu/dynamic/$Proxy0.class");
        os.write(bytes);
        os.close();
    }
}
